package com.kingyea.app.market.file.service.impl;

import com.kingyea.app.market.file.bean.File;
import com.kingyea.app.market.file.dao.FileMapper;
import com.kingyea.app.market.file.service.FileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author CXC
 * @version v1.0.0
 * @description File 实现类
 * @date Created in 2018-03-22 16:52:24
 */
@Service
@Transactional
public class FileServiceImpl implements FileService {

    private static final Logger LOGGER = LoggerFactory.getLogger(FileServiceImpl.class);

    @Resource
    private FileMapper fileMapper;

    /**
     * 列表
     *
     * @param
     * @return
     */
    @Override
    public List<File> list(File file) throws Exception {
        List<File> list = fileMapper.list(file);
        return list;
    }

    /**
     * 删除
     *
     * @param
     * @return
     */
    @Override
    public boolean delete(File file) throws Exception {
        return fileMapper.delete(file) > 0;
    }

    /**
     * 保存
     *
     * @param file
     * @return
     */
    @Override
    public boolean save(File file) throws Exception {
        try {
            return fileMapper.save(file) > 0;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 更新
     *
     * @param file
     * @return
     */
    @Override
    public boolean update(File file) throws Exception {
        try {
            return fileMapper.update(file) > 0;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

}
